package org.bmind.datasword.exec.dto;

import org.bmind.datasword.config.dto.DDataType;
import org.bmind.datasword.utils.EqualsUtil;
import org.bmind.datasword.utils.HashCodeUtil;

public class DExecFunctionParameters {
	
	private int fHashCode;
	private int id = 0;
	private String parName = null;
	private DDataType dataType = null;
	private Object parValue = null;
	
	public DExecFunctionParameters() {super();}

	public String getParName() {return parName;}
	public void setParName(String parName) {this.parName = parName;}
	
	public int getId() {return id;}
	public void setId(int id) {this.id = id;}

	public DDataType getDataType() {return dataType;}
	public void setDataType(DDataType dataType) {this.dataType = dataType;}

	public Object getParValue() {return parValue; }
    public void setParValue(Object parValue) {this.parValue = parValue;}

	/* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
	   
  	  if ( this == obj ) return true;
	    if ( !(obj instanceof DExecFunctionParameters) ) return false;
	    DExecFunctionParameters dEFP = (DExecFunctionParameters)obj;
    	
    	return	EqualsUtil.areEqual(this.parName, dEFP.parName) &&
    			EqualsUtil.areEqual(this.id, dEFP.id) &&
    			EqualsUtil.areEqual(this.dataType, dEFP.dataType ) &&
    			EqualsUtil.areEqual(this.parValue, dEFP.parValue);
    }
   
	/* (non-Javadoc)
     * @see org.bmind.datasword.config.dto.DObjCommon#hashCode()
     */
	@Override
	public int hashCode() {
		
		// this style of lazy initialization is
		// suitable only if the object is immutable
		if (fHashCode == 0) {
		int result = HashCodeUtil.SEED;
			result = HashCodeUtil.hash(result, getId());
			result = HashCodeUtil.hash(result, getDataType());
			result = HashCodeUtil.hash(result, getParName());
			result = HashCodeUtil.hash(result, getParValue());
			fHashCode = result;
		}
		return fHashCode;
	}
}
